Skip to content

fix(billing): hand off billing to hosted console - #408

Merged
lucas77778 merged 10 commits into
masterfrom
chenyu/code-567
Aug 17, 2026
Merged

fix(billing): hand off billing to hosted console#408
lucas77778 merged 10 commits into
masterfrom
chenyu/code-567

Conversation

@lucas77778

@lucas77778 lucas77778 commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace LinkCode's balance, offers, orders, subscription, portal, custom amount, and checkout implementation with a single hosted billing handoff built by the official @linkcode/cloud SDK.
  • Desktop exposes only openHostedBilling(): main registers the current linkcode:// / linkcode-dev:// scheme, builds https://console.linkcode.ai/billing?returnTarget=..., and opens it in the system browser.
  • Webview builds the credential-free hosted URL through the same SDK and opens it in a new browser tab.
  • Reduce the shared UI contract to BillingSettingsPanel({ onOpenBilling }); LinkCode does not request, store, render, or infer billing/checkout/payment state.
  • Remove the sidebar balance shortcut and all LinkCode billing API sources, providers, IPC channels, and preload methods.

Linear: CODE-567
Cloud counterpart: arcboxlabs/linkcodehq#39 at 5438df8c8083f349dc3b8ed3eccdd61ca9d86358

Contracts

  • Cloud SDK: createHostedBillingUrl(options?: { returnTarget?: string }): string; HostedBillingUrlOptions is exported.
  • Hosted surface: https://console.linkcode.ai/billing[?returnTarget=<encoded>].
  • Desktop return target: ${scheme}://billing/return, where scheme is linkcode in packaged builds and linkcode-dev in development.
  • Cloud's existing native return bridge appends authoritative order=<id> and, on cancellation, canceled=true. Desktop deliberately does not parse either parameter and does not process checkout; the existing generic deep-link path only activates/focuses the app.
  • Until the initial public npm bootstrap of @linkcode/[email protected], this repository consumes the official package tarball built from the Cloud commit above, pinned at SHA-256 576bf95543503615204163609c49fe66ad38a3081babf5b93369a94842acdb7b.

Verification

  • NODE_OPTIONS=--max-old-space-size=6144 pnpm check:ci — passed: format, repo-wide ESLint (0 errors; 377 existing warnings), and typecheck.
  • pnpm test — passed: 307 files / 2443 tests; 1 existing skipped file/test.
  • Hosted handoff unit tests — passed for Desktop main, Webview route, and shared Billing panel.
  • pnpm -F @linkcode/desktop run build — passed.
  • pnpm -F @linkcode/webview run build — passed.
  • pnpm -F @linkcode/webview e2e:browser — passed production billing-route smoke plus bundled mock router/wire/reload smoke.
  • Bundle inspection found the Cloud hosted URL and no checkout-sessions, billing summary/orders, or portal-session endpoints.
  • Built Desktop Electron smoke — opened the Billing settings page, launched a second instance with linkcode-dev://billing/return?order=...- Commit hookscanceled=true, observed one restored/focused window, and observed no local checkout-result UI.
  • Commit hooks — passed large-file policy, formatting/imports, lint, and typecheck.

Checklist

  • pnpm check:ci and pnpm test both pass
  • I ran the affected surface and observed the change working
  • No wire message changed
  • The vendored SDK tarball comes from the official Cloud package/commit documented above
  • Docs and comments are updated where behavior changed

Copilot AI lite review requested due to automatic review settings August 3, 2026 14:58
@linear-code

linear-code Bot commented Aug 3, 2026

Copy link
Copy Markdown

CODE-567

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings August 4, 2026 04:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@lucas77778 lucas77778 changed the title feat(billing): add LinkCode billing surface fix(billing): hand off billing to hosted console Aug 4, 2026
@lucas77778
lucas77778 requested review from AprilNEA and Zerlight and a lite review from Copilot August 4, 2026 07:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings August 5, 2026 02:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@lucas77778
lucas77778 requested a review from PeronGH August 5, 2026 05:00

@PeronGH PeronGH left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two correctness issues on the typed gateway-billing path; details inline.

Comment thread packages/host/agent-adapter/src/native/claude-code.ts Outdated

@PeronGH PeronGH left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction to my earlier 503 comment (retracted inline — the mapping is contract-backed), and the real problem the Cloud contract exposes instead.

Comment thread packages/presentation/i18n/src/locales/en.ts Outdated
Amp-Thread-ID: https://ampcode.com/threads/T-01a00600-4239-75bb-8431-db3461ff7e4c

# Conflicts:
#	apps/desktop/src/main/cloud-auth/client.ts
#	packages/client/workbench/src/settings/providers/__tests__/add-flow.test.tsx
#	packages/client/workbench/src/settings/providers/add-flow.tsx
#	packages/client/workbench/src/settings/providers/catalog.ts
#	packages/client/workbench/src/settings/providers/providers-settings.tsx
#	packages/host/agent-adapter/src/native/claude-code.ts
#	packages/presentation/i18n/src/locales/en.ts
#	packages/presentation/i18n/src/locales/zh-cn.ts
#	packages/presentation/ui/src/shell/conversation-surface.tsx
#	packages/presentation/ui/src/shell/providers/account-detail.tsx
#	packages/presentation/ui/src/shell/providers/account-master-list.tsx
Copilot AI review requested due to automatic review settings August 16, 2026 06:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings August 16, 2026 10:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@lucas77778
lucas77778 requested a review from PeronGH August 17, 2026 05:22
Copilot AI review requested due to automatic review settings August 17, 2026 05:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@PeronGH PeronGH left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the change itself — but do not merge until the Cloud side is merged and deployed.

The gate is the deploy, not the merge. https://console.linkcode.ai/billing does not exist in production today: it and /zzz-does-not-exist both return 200 with the identical [organizationSlug] catch-all entry (<title>LinkCode</title>), i.e. prod treats billing as an org slug. The hosted route only exists on feat/code-567-hosted-billing-sdk, and linkcodehq has no deploy workflow — the console ships via a manual pnpm --filter @linkcodehq/console deploy. So merging arcboxlabs/linkcodehq#39 alone still leaves openHostedBilling() opening a dead end, and desktop cuts releases off master.

Order:

  1. Land arcboxlabs/linkcodehq#39 — its only conflict is pnpm-lock.yaml (checked with git merge-tree), so resolving it cannot change packages/cloud/src or the route, and the pin below stays valid.
  2. Deploy the console, then verify https://console.linkcode.ai/billing?returnTarget=linkcode://billing/return renders the Billing entry and preserves the target through sign-in + organization resolution.
  3. Merge this PR.

What is not blocking:

  • The npm publish. packages/vendor/linkcode-cloud-0.1.0.tgz is sha256 576bf95543503615204163609c49fe66ad38a3081babf5b93369a94842acdb7b as documented, and its dist/index.js is faithful to packages/cloud/src/index.ts at 5438df8c. The cloud-v0.1.0 tag and npm bootstrap are a follow-up.
  • Everything outside the hosted handoff. The Gateway provider, the typed 402/503 path, and API-key creation depend only on Cloud work already merged and live: gateway.linkcode.ai/v1/models → 401, api.linkcode.ai/auth/get-session → 200, /auth/api-key/create → 400.

Both of my earlier findings are addressed — fix(gateway): preserve translated billing errors for the dead typed-error path on claude-code, and billingUnavailableHint no longer promises the request never reached the model.

Please open a follow-up issue for the vendored tarball: once @linkcode/[email protected] is on npm, swap the file: dependency for the registry package and delete the blob (@linkcode/[email protected] is the precedent). That swap will need a minimumReleaseAgeExclude entry for the fresh publish.

@lucas77778
lucas77778 merged commit b72ba7c into master Aug 17, 2026
15 checks passed
@lucas77778
lucas77778 deleted the chenyu/code-567 branch August 17, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants